/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistencia;

import java.sql.*;


/**
 *
 * @author v3550
 */
public class DaoConnection {

    protected String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver";
    protected String jdbc_string;
    protected String user_name;
    protected String passwd;
    protected Connection conn = null;

    public Connection setConnection(String name, String passWord, String host, String port, String sid) throws Exception{
        System.gc(); 
        if(this.getConnection() != null) 
            this.getConnection().close();
        this.user_name = name.toUpperCase();
        this.passwd = passWord.toUpperCase();
        this.jdbc_string = "jdbc:oracle:thin:@" + host + ":" + port + ":" + sid;
        Class.forName(JDBC_DRIVER);
        return (conn = DriverManager.getConnection(this.jdbc_string, this.user_name, this.passwd));
    }

   
    public Connection getConnection() {
        return this.conn;
    }

    public void closeConnection() throws SQLException {
        this.conn.close();
    }

   
}
